#include "list.hpp"
#include <list>

using namespace mylist;
void test0()
{
    mylist::list<int> l;
    l.push_back(1);
    l.push_back(2);
    l.push_back(3);
    l.push_back(4);
    l.print();

    l.push_front(90);
    l.print();

    l.push_front(80);
    l.print();

    l.pop_front();
    l.print();
    l.pop_front();
    l.print();
    l.pop_front();
    l.print();
}

void test1()
{
    mylist::list<int> tmp;

    for (int i = 0; i < 5; i++)
    {
        tmp.push_back(i);
    }

    mylist::list<int> li(tmp);
    auto it = tmp.begin();
    while (it != tmp.end())
    {
        std::cout << *it << " ";
        ++it;
    }
    std::cout << std::endl;

    it = li.begin();
    while (it != li.end())
    {
        std::cout << *it << " ";
        ++it;
    }
    std::cout << std::endl;
}
void test2()
{
    std::list<int> li({1, 2, 3, 4, 5});
    auto it = li.begin()++;
    std::cout << *it << std::endl;

    auto it1 = li.insert(it, 5);
    std::cout << *it << std::endl;

    std::cout << *it1 << std::endl;
}
void test3()
{
}
void test4()
{
    mylist::list<int> it;
    it.pop_front();
}
struct A
{
    int a;
    int b;
    A(int x = 0, int y = 0) : a(x), b(y)
    {
    }
};
void test5()
{
    mylist::list<A> ls;
    ls.push_back({1, 3});
    ls.push_back({3, 4});

    auto it = ls.end();
    it--;
    while (it != ls.end())
    {
        std::cout << it->a << it->b << std::endl;
        it--;
    }
}
int main()
{

     test0();
     test1();
     test2();
     test3();
     //test4();
     test5();


    return 0;
}